home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
term
/
extras
/
source
/
term-source.lha
/
MiscPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-17
|
9KB
|
397 lines
/*
** MiscPanel.c
**
** Editing panel for miscellaneous parts of the configuration
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_USE=1000,GAD_CANCEL,GAD_DEFAULT,
GAD_PAGER,GAD_PAGEGROUP,
GAD_REQUESTERMODE,GAD_SET_REQUESTERSIZE
};
STATIC LONG __saveds
ShowSize(struct Gadget *SomeGadget,WORD Level)
{
return(1L << Level);
}
BYTE __regargs
MiscPanel(struct Configuration *Config,BYTE *Default)
{
STATIC BYTE InitialPage = 0;
struct LayoutHandle *Handle;
BYTE Cancel = FALSE;
STRPTR PageTitle[4];
STATIC LONG PageTitleID[] =
{
MSG_V36_0107,
MSG_V36_0108,
MSG_USER_INTERFACE_TXT,
-1
};
LocalizeStringTable(PageTitle,PageTitleID);
SaveConfig(Config,PrivateConfig);
if(Handle = LT_CreateHandleTags(Window -> WScreen,
LH_LocaleHook, &LocaleHook,
LH_ExitFlush, FALSE,
TAG_DONE))
{
struct Window *PanelWindow;
WORD i,BufferSize;
for(i = 0 ; i < 32 ; i++)
{
if((1L << i) == Config -> MiscConfig -> IOBufferSize)
{
BufferSize = i;
break;
}
}
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, CYCLE_KIND,
LA_ID, GAD_PAGER,
LA_LabelID, MSG_XFER_PAGE_TXT,
GTCY_Labels, PageTitle,
LACY_AutoPageID,GAD_PAGEGROUP,
LACY_TabKey, TRUE,
LA_BYTE, &InitialPage,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_ID, GAD_PAGEGROUP,
LAGR_Frame, TRUE,
LAGR_ActivePage,InitialPage,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MISCPANEL_BACKUP_CONFIGURATION_GAD,
LA_BYTE, &Config -> MiscConfig -> BackupConfig,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MISCPANEL_SHOW_FAST_MACROS_GAD,
LA_BYTE, &Config -> MiscConfig -> OpenFastMacroPanel,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MISCPANEL_RELEASE_SERIAL_DEVICE_GAD,
LA_BYTE, &Config -> MiscConfig -> ReleaseDevice,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MISCPANEL_SIMPLE_IO_GAD,
LA_BYTE, &Config -> MiscConfig -> SimpleIO,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_OVERWRITE_WARNING_TXT,
LA_BYTE, &Config -> MiscConfig -> ProtectiveMode,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MISCPANEL_CREATE_ICONS_GAD,
LA_BYTE, &Config -> MiscConfig -> CreateIcons,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_MISCPANEL_PROGRAM_PRIORITY_GAD,
GTSL_Min, -128,
GTSL_Max, 127,
GTSL_LevelFormat, "%4ld",
LA_BYTE, &Config -> MiscConfig -> Priority,
LA_Chars, 12,
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_V36_1810,
LA_WORD, &BufferSize,
GTSL_Min, 12,
GTSL_Max, 20,
GTSL_DispFunc, ShowSize,
GTSL_LevelFormat, LocaleBase ? "%7lD" : "%7ld",
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, CYCLE_KIND,
LA_LabelID, MSG_TERMINALPANEL_ALERT_GAD,
LA_BYTE, &Config -> MiscConfig -> AlertMode,
LACY_FirstLabel,MSG_TERMINALPANEL_ALERT_NONE_TXT,
LACY_LastLabel, MSG_TERMINALPANEL_ALERT_SIGNAL_SCREEN_TXT,
TAG_DONE);
LT_New(Handle,
LA_Type, XBAR_KIND,
TAG_DONE);
LT_New(Handle,
LA_Type, CYCLE_KIND,
LA_LabelID, MSG_REQUESTER_DIMENSIONS_TXT,
LA_BYTE, &Config -> MiscConfig -> RequesterMode,
LACY_FirstLabel,MSG_LABEL_CENTRE_TXT,
LACY_LastLabel, MSG_LABEL_IGNORE_TXT,
LA_ID, GAD_REQUESTERMODE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_REQUESTER_EDIT_SIZE_TXT,
LA_ID, GAD_SET_REQUESTERSIZE,
GA_Disabled, Config -> MiscConfig -> RequesterMode == REQUESTERMODE_IGNORE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, XBAR_KIND,
LAXB_FullSize, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,LA_Type,HORIZONTAL_KIND,
LAGR_SameSize, TRUE,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_USE_GAD,
LA_ID, GAD_USE,
LABT_ReturnKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
if(Default)
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_DEFAULT_GAD,
LA_ID, GAD_DEFAULT,
LABT_ExtraFat, TRUE,
TAG_DONE);
}
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_CANCEL_GAD,
LA_ID, GAD_CANCEL,
LABT_EscKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_MISCPANEL_MISCELLANEOUS_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
LAWN_Parent, Window,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
WA_Activate, TRUE,
TAG_DONE))
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
struct FileRequester *FileRequester = NULL;
BOOL JustCreated;
GuideContext(CONTEXT_MISC);
PushWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
do
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
{
SaveConfig(PrivateConfig,Config);
break;
}
while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW)
{
SaveConfig(PrivateConfig,Config);
Done = TRUE;
}
if(MsgClass == IDCMP_GADGETUP)
{
switch(MsgGadget -> GadgetID)
{
case GAD_REQUESTERMODE:
LT_SetAttributes(Handle,GAD_SET_REQUESTERSIZE,
GA_Disabled,Config -> MiscConfig -> RequesterMode == REQUESTERMODE_IGNORE,
TAG_DONE);
break;
case GAD_SET_REQUESTERSIZE:
LT_LockWindow(PanelWindow);
if(!FileRequester)
{
if(FileRequester = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
ASLFR_Window, PanelWindow,
ASLFR_TitleText, LocaleString(MSG_MOVE_RESIZE_THIS_WINDOW_TXT),
ASLFR_PositiveText, LocaleString(MSG_GLOBAL_USE_GAD),
TAG_DONE))
JustCreated = TRUE;
}
if(FileRequester)
{
BOOL Result;
if(JustCreated && (!Config -> MiscConfig -> RequesterWidth || !Config -> MiscConfig -> RequesterHeight))
JustCreated = FALSE;
Result = AslRequestTags(FileRequester,
ASLFR_InitialLeftEdge, Window -> LeftEdge + Config -> MiscConfig -> RequesterLeft,
ASLFR_InitialTopEdge, Window -> TopEdge + Config -> MiscConfig -> RequesterTop,
JustCreated ? ASLFR_InitialWidth : TAG_IGNORE, Config -> MiscConfig -> RequesterWidth,
JustCreated ? ASLFR_InitialHeight : TAG_IGNORE, Config -> MiscConfig -> RequesterHeight,
TAG_DONE);
if(!Result && IoErr())
Result = AslRequest(FileRequester,NULL);
if(Result)
{
Config -> MiscConfig -> RequesterLeft = FileRequester -> fr_LeftEdge - Window -> LeftEdge;
Config -> MiscConfig -> RequesterTop = FileRequester -> fr_TopEdge - Window -> TopEdge;
Config -> MiscConfig -> RequesterWidth = FileRequester -> fr_Width;
Config -> MiscConfig -> RequesterHeight = FileRequester -> fr_Height;
}
JustCreated = FALSE;
}
LT_UnlockWindow(PanelWindow);
break;
case GAD_USE:
Config -> MiscConfig -> IOBufferSize = 1L << BufferSize;
Done = TRUE;
break;
case GAD_CANCEL:
SaveConfig(PrivateConfig,Config);
Cancel = Done = TRUE;
break;
case GAD_DEFAULT:
*Default = TRUE;
Done = TRUE;
break;
}
}
}
}
while(!Done);
if(FileRequester)
FreeAslRequest(FileRequester);
PopWindow();
}
LT_DeleteHandle(Handle);
}
if(Default)
return((BYTE)(!Cancel));
else
return((BYTE)memcmp(PrivateConfig -> MiscConfig,Config -> MiscConfig,sizeof(struct MiscSettings)));
}